package com.yelobblog.yelobblog.common.untils;

import com.yelobblog.yelobblog.common.exception.ErrorEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Response<T> {
    private int code;
    private String msg;
    private T data;

    public static <E> Response<E> success(E data) {
        return new Response<>(ErrorEnum.SUCCESS.getErrorCode(),ErrorEnum.SUCCESS.getErrorMsg(), data);
    }
    public static <E> Response<E> success() {
        return new Response<>(ErrorEnum.SUCCESS.getErrorCode(),ErrorEnum.SUCCESS.getErrorMsg(), null);
    }
    public static <E> Response<E> fail(int code,String msg) {
        return new Response<>(code, msg, null);
    }
}
